package com.xy.controller.express;


import com.alibaba.fastjson.JSONArray;
import com.xy.common.base.ApiBaseResponse;
import com.xy.entity.express.express100.ExpressDetail;
import com.xy.repository.express.NoticeDataRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;




@Api(value = "快递轨迹controller", description = "查询快递接口")
@RestController
public class UserExpressController {
    @Autowired
    private NoticeDataRepository noticeDataRepository;

    @ApiOperation("物流查询")
    @ResponseStatus(HttpStatus.OK)
    @PostMapping(value = "/userexpress")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="nu",value = "快递单号",required=true)
    })
    @Transactional
    public ResponseEntity findExpressDetail(@RequestParam("nu") String nu){



        ExpressDetail expressDetail = noticeDataRepository.findByNu(nu);

        String datas=expressDetail.getData();

        JSONArray jsonArray=JSONArray.parseArray(datas);



        return ResponseEntity.ok(ApiBaseResponse.fromHttpStatus(HttpStatus.OK,jsonArray));
    }

}
